<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>数据类型转换为字符串和布尔型</title>
</head>

<body>
  <script>
    // 转化为字符型
    // String方法  推荐使用
    let num = 1
    console.log(typeof String(num))

    // 转化为布尔类型   !!
    // false  0 '' null undefined  NaN
    let flag = true
    console.log(Boolean(false));
    console.log(Boolean(0));
    console.log(Boolean(''));
    console.log(Boolean(null));
    console.log(Boolean(undefined));
    console.log(Boolean(NaN));

    // !!强制类型转换
    console.log(Boolean(!!!0));






  </script>
</body>

</html>